#include <iostream>
#include <cstdio>
#include <algorithm>
#include <map>
#include <cstring>
#include <vector>
#include<queue>
using namespace std;
void lon_2(long long x)
{
	long long k = 0,y=1;
	x = x + 1;
	while (x >= y) 
	{
		y = y * 2;
		k++;
	}
	y = y / 2;
	cout << k - 1 << ' ' << x - y << endl;
}
int main()
{
	long long n,sum=0;
	double x = 10;
	cin >> n;
	while (n--)
	{
		double s;
		int b;
		cin >> s >> b;
		x = x - s;
		if (x > 10)
			x = 10;
		else if (x <= 0)
			break;
		sum += b;
	}
	 lon_2(sum);
	return 0;
}